var express = require('express');
var router = express.Router();

const { deleteShopsById, addShops,getShopsBystate, getShops, updateShopsById, searchApplys,shopsDeleteApply,updateApplyById,deleteApplysById } = require("../server/shopsServer.js")

// 删除
router.post('/deleteShopsById', async (req, res) => {
  res.send(await deleteShopsById(req.body));
});
// 新增
router.post('/addShops', async (req, res, next) => {
  const data = await addShops(req.body)
  res.send(data)
});
//获取
router.get('/', async (req, res, next) => {
  const data = await getShops(req.query)
  res.send(data)
});
//搜索查询门店申请
router.get('/searchApplys', async (req, res) => {
  console.log(req.query)
  res.send(await searchApplys(req.query));
});
  // router.get('/getShopsById', async (req, res, next) => {
  //   const data = await getShops(req.query)
  //   res.send(data)
  // });
router.post('/updateShopsById', async (req, res) => {
  res.send(await updateShopsById(req.body));
});

//注销申请
router.post('/shopsDeleteApply', async (req, res) => {
  res.send(await shopsDeleteApply(req.body));
});

//驳回修改状态为status:3； 同意修改状态为status:2
router.post('/updateApplyById', async (req, res) => {
  res.send(await updateApplyById(req.body));
});


router.post('/deleteApplysById', async (req, res) => {
  res.send(await deleteApplysById(req.body));
});
//获取请求通过的门店
router.get('/getShopsBystate', async (req, res) => {
  console.log(req.query)
  res.send(await getShopsBystate(req.query));
});

module.exports = router;